# coding:utf-8

"""
tf_demo02_session
Created on 2016/12/9 14:06
@author: GuoYufu
@group : OceanHorn
@contact: OceanHorn@163.com
"""

import tensorflow as tf

def session_method_1(product):
    print "Method 1"
    session = tf.Session()
    result = session.run(fetches=product)
    print result
    session.close()
    print "End of Method 1"

def session_method_2(product):
    print "Method 2"
    with tf.Session() as session:
        result = session.run(fetches=product)
        print result
        print "End of Method 2"


if __name__ == "__main__":
    matrix1 = tf.constant([[3, 3]])
    print type(matrix1)
    matrix2 = tf.constant([[2],
                           [2]])

    product = tf.matmul(matrix1, matrix2)

    session_method_1(product)
    session_method_2(product)
